package com.hxzy.controller.admin.employee.resp;

import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import com.alibaba.excel.annotation.write.style.ContentRowHeight;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.hxzy.common.annotates.DictTypeProperty;
import com.hxzy.common.constants.MarketConstants;
import com.hxzy.common.enums.DictTypeEnum;
import com.hxzy.common.exsyexcel.DictDataConvert;
import com.hxzy.common.exsyexcel.ImageConvert;
import lombok.Getter;
import lombok.Setter;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.Date;

/**
 * 自定义返回对象
 */
@Getter
@Setter
@JsonInclude(value = JsonInclude.Include.NON_NULL)
@ContentRowHeight(110)
public class EmployeeResp {


    @ExcelProperty(value="主键")
    private Long id;

    /**
     * 登录账户
     */
    @ExcelProperty(value="登录账户")
    private String loginName;

    /**
     * 性别(0 女 1 男)
     */
    @DictTypeProperty(value= DictTypeEnum.SYS_USER_SEX)
    @ExcelProperty(value="性别",converter = DictDataConvert.class)
    private String gender;

    /**
     * 状态（1停用，0正常）
     */
    @DictTypeProperty(value=DictTypeEnum.SYS_NORMAL_DISABLE)
    @ExcelProperty(value="状态",converter = DictDataConvert.class)
    private String status;

    /**
     * 头像
     */
    @ColumnWidth(25)
    @ExcelProperty(value="头像", converter = ImageConvert.class)
    private String avatar;


//    @ExcelIgnore
//    private String avatar;

//    @JsonIgnore
//    @ExcelProperty(value="头像")
//    private URL url;
//
//    @JsonIgnore
//    public URL getUrl() throws MalformedURLException {
//        return new URL(this.avatar);
//    }


    /**
     * 创建时间
     */
    @ColumnWidth(20)
    @ExcelProperty(value="创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date createTime;

    /**
     * 1超级管理员，0普能后台用户
     */
    @ExcelProperty(value="是否超级管理员")
    private String root;

    public String getRoot() {
        return root.equals(MarketConstants.ACCOUT_DISABLE)?"是":"否";
    }
}
